﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LMKJ.Classes;
using System.Collections;

namespace LMKJ
{
    public partial class viewshoppinglistdetails : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                int lid = Convert.ToInt32(Request.QueryString["details"]);

                ShoppingList sl = DatabaseManager.RetrieveShoppingListById(lid);

                if (sl != null)
                {
                    lidLbl.Text = lid.ToString();
                    nricLbl.Text = sl.Nric;
                    vidLbl.Text = sl.Volunteer_id.ToString();
                    dateLbl.Text = sl.Date;
                    dateReqLbl.Text = sl.Date_req;
                    datePurLbl.Text = sl.Date_pur;
                    dateDelLbl.Text = sl.Date_del;
                    statusLbl.Text = sl.Status;

                    ArrayList itemsList = DatabaseManager.RetrieveItemListByListId(lid);

                    foreach (ItemList i in itemsList)
                    {
                        itemsListLbox.Items.Add(i.Item_name + " - " + i.Qty);
                    }
                }
            }
        }

        protected void editBtn_Click(object sender, EventArgs e)
        {
            Response.Redirect("editshoppinglist.aspx?details=" + lidLbl.Text);
        }

        protected void backBtn_Click(object sender, EventArgs e)
        {
            Response.Redirect("searchshoppinglists.aspx");
        }
    }
}